#include <iostream>

using namespace std;
typedef long long LL;

LL gcd(LL a, LL b)
{
	return b ? gcd(b, a % b): a;
}
LL x, y;
int main()
{
	cin >> x >> y;
	LL n = x * y;
	LL ret = 0;
	for (int p = 1; p <= n / p; p++)
	{
		if (n % p) continue;
		LL q = n / p;
		if (gcd(p, q) == x)
		{
			ret += 2;
			if (q == p) ret--;
		}
	}
	cout << ret << endl;
	return 0;
}